import instance from './request'

// 下单
export const reqCommitOrder = (data) => {
  return instance({
    url: '/api/commitorder',
    method: 'post',
    data,
  })
}

// 获取指定订单信息
export const reqOrderInfo = (order_id) => {
  return instance({
    url: '/api/getorder?order_id=' + order_id,
    method: 'post',
  })
}

// 付款二维码链接
export const reqWxPay = ({ order_id, total_price, openid = '' }) => {
  return instance({
    url: '/api/wxpay',
    method: 'post',
    data: { order_id, total_price, openid },
  })
}

// 查询订单状态
export const reqQueryPayOrder = (order_id) => {
  return instance({
    url: '/api/queryPayOrder?order_id=' + order_id,
    method: 'post',
  })
}

// 查询物流信息
export const reqOrderFlow = () => {
  return instance({
    url: '/api/kuaidi',
  })
}

// 获取用户订单
export const reqUserOrder = () => {
  return instance({
    method: 'post',
    url: '/api/userorder',
  })
}

// 取消订单
export const reqCancelOrder = (order_id) => {
  return instance({
    method: 'post',
    url: `/api/cancelorder?order_id=${order_id}`,
  })
}

// 删除订单
export const reqDelOrder = (order_id) => {
  return instance({
    method: 'post',
    url: `/api/delorder?order_id=${order_id}`,
  })
}
